-- attack_tear
-- created by shuzy
-- 攻击附加撕裂

return {
    apply = function(prop, baseValue)
        return prop[2];
    end,

    -- 攻击触发
    trigger = function(who, prop, arg)
        local target = arg;

        -- 概率触发
        local rand = DungeonM.getRandSeed("attack_tear") % 1000;

        if (rand > prop[3]) then
            return;
        end

        -- 获取攻击方基础攻击
        local attack = InterfaceM.calcBaseAttrib(ME.user, "attack");

        local propId = PropM.getPropId("tear");
        local v = math.modf(attack * prop[2] / 1000);

        -- 伤口的伤害百分比加
        local p = PropM.combine(ME.user, "tear_force_add", 1);
        v = PropM.apply(p, v);

        -- 伤口的持续轮数加
        p = PropM.combine(ME.user, "tear_round_add", 1);
        local effectRound = CombatM.getRound() + PropM.apply(p, prop[4]);

        -- 减益状态
        local arr = ({ propId, 1, v, effectRound, });

        local condition = {
            ["prop"] = arr,
            ["end_round"] = effectRound,
        };

        -- 附加状态
        CombatStatusM.applyStatus(target, "tear", condition);

        return arr;
    end,

    record = function(target, prop, path)
        return false;
    end
};
